﻿#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/PagedLOD>
#include <osgViewer/ViewerEventHandlers>

int main()
{
	osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();

	/*osg::ref_ptr<osg::PagedLOD> plod = new osg::PagedLOD();
	plod->addChild(osgDB::readNodeFile("glider.osg"), 0.0f, 10.0f);
	plod->addChild(osgDB::readNodeFile("cow.osg"), 10.0f, 100.0f);
	plod->addChild(osgDB::readNodeFile("ceep.ive"), 100, 1000);
	viewer->setUpViewInWindow(100, 100, 1920, 1080);
	viewer->setSceneData(plod);*/

	viewer->addEventHandler(new osgViewer::HelpHandler);
	viewer->addEventHandler(new osgViewer::StatsHandler());
	viewer->setUpViewInWindow(100, 100, 1920, 1080);
	viewer->setSceneData(osgDB::readNodeFile("taibei_osgd/314341526351/Block.osgb"));
	
	// 注释和打开下面的代码，在拉近场景时观察任务管理器里这个程序的内存占用情况
	osgDB::DatabasePager* dp = viewer->getDatabasePager();
	dp->setTargetMaximumNumberOfPageLOD(1);

	return viewer->run();
}